﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using TomNet.Web.Mvc.UI;

namespace TomNet.IMSC.Web.Common
{
    public static class SendMessage
    {
        public static AjaxResult SendMessge(string Phone, string Message)
        {
            AjaxResult result = new AjaxResult();
            result.Type = AjaxResultType.Error;
            result.Content = "失败";
            WebClient wc = new WebClient();
            wc.Encoding = System.Text.Encoding.UTF8;
            string str = "http://124.172.234.157:8180/Service.asmx/SendMessageStr?Id=300&Name=LD0656&Psw=" + TomNet.Utility.Secutiry.HashHelper.GetMd5("8888").ToUpper() + "&Message=" + Message + "&Timestamp=0&Phone=" + Phone;
            string jieguostr = wc.DownloadString(str).Split(new char[] { ',' })[0].Split(new char[] { ':' })[1];
            switch (jieguostr)
            {
                case "1":
                    result.Type = AjaxResultType.Success;
                    result.Content = "发送短信成功！";
                    break;
                case "-1":
                    result.Content = "发送失败";
                    break;
                case "-5":
                    result.Content = "发送短信内容为空";
                    break;
                case "-6":
                    result.Content = "短信内容过长";
                    break;
                case "-7":
                    result.Content = "发送号码为空";
                    break;
                case "-8":
                    result.Content = "余额不足";
                    break;
                case "-9":
                    result.Content = "接收数据失败";
                    break;
                case "-10":
                    result.Content = "发送失败 号码错误";
                    break;
                case "-13":
                    result.Content = "内容信息含关键字";
                    break;
                case "-14":
                    result.Content = "信息内容格式与限定格式不符";
                    break;
                case "-15":
                    result.Content = "信息没带签名";
                    break;
                case "-16":
                    result.Content = "黑名单号码";
                    break;
                case "-100":
                    result.Content = "客户端获取状态失败";
                    break;
                default:
                    break;
            }
            return result;

        }
        public static AjaxResult SendMessgeYanZhengMa(string Phone, string YanZhengMa)
        {
            return SendMessge(Phone, "【新房天下】您本次操作的验证码" + YanZhengMa + "，5分钟以内有效");
        }
    }
}